#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{

  printf("I am a parent process,pid:%d\n",getpid());

  pid_t id = fork();
  if(id < 0)
  {
    return 1;
  }
  else if(id == 0)
  {
    //子进程
    while(1)
    {
      printf("I am a child process,pid:%d,ppid:%d\n",getpid(),getppid());
      sleep(1);
    }
  }
  else
  {
    //父进程
    while(1)
    {
      printf("I am a parent process,pid:%d,ppid:%d\n",getpid(),getppid());
      sleep(1);
    }
  }

  return 0;
}
